package com.kanqiubao.kq.activity.user;

import android.os.Bundle;

import com.chad.library.adapter.base.listener.GridSpanSizeLookup;
import com.kanqiubao.kq.R;
import com.kanqiubao.kq.activity.BaseActivity;
import com.kanqiubao.kq.adapter.user.UserHistoryListAdapter;
import com.kanqiubao.kq.bean.main.MainOneListBean;

import java.util.ArrayList;
import java.util.List;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

public class UserHistoryListActivity extends BaseActivity<String> {
    private RecyclerView mRecyclerView;
    private UserHistoryListAdapter mUserHistoryListAdapter;

    @Override
    protected void onActivityCreate(Bundle savedInstanceState) {
        mRecyclerView=findView(R.id.recy_id);
        mUserHistoryListAdapter=new UserHistoryListAdapter();
        mRecyclerView.setLayoutManager(new GridLayoutManager(this,2));
        mUserHistoryListAdapter.setGridSpanSizeLookup(new GridSpanSizeLookup() {
            @Override
            public int getSpanSize(@NonNull GridLayoutManager gridLayoutManager, int viewType, int position) {
                if(mUserHistoryListAdapter.getItem(position).getItemType()== MainOneListBean.GROUP){
                    return  2;
                }
                return 1;
            }
        });
        mRecyclerView.setAdapter(mUserHistoryListAdapter);
        List<MainOneListBean> item = new ArrayList<>();
        item.add(new MainOneListBean(MainOneListBean.GROUP));
        item.add(new MainOneListBean(MainOneListBean.ITEM));
        item.add(new MainOneListBean(MainOneListBean.ITEM));
        item.add(new MainOneListBean(MainOneListBean.GROUP));
        item.add(new MainOneListBean(MainOneListBean.ITEM));
        item.add(new MainOneListBean(MainOneListBean.ITEM));
        item.add(new MainOneListBean(MainOneListBean.ITEM));
        item.add(new MainOneListBean(MainOneListBean.ITEM));
        item.add(new MainOneListBean(MainOneListBean.GROUP));
        item.add(new MainOneListBean(MainOneListBean.ITEM));
        item.add(new MainOneListBean(MainOneListBean.ITEM));
        item.add(new MainOneListBean(MainOneListBean.ITEM));
        item.add(new MainOneListBean(MainOneListBean.ITEM));
        item.add(new MainOneListBean(MainOneListBean.GROUP));
        item.add(new MainOneListBean(MainOneListBean.ITEM));
        item.add(new MainOneListBean(MainOneListBean.ITEM));
        item.add(new MainOneListBean(MainOneListBean.ITEM));
        item.add(new MainOneListBean(MainOneListBean.ITEM));
        mUserHistoryListAdapter.addData(item);
    }

    @Override
    protected int getActivitylayout() {
        return R.layout.user_history_layout;
    }

    @Override
    protected String getTitleText() {
        return "观看历史";
    }
}
